In [1]:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import plotly.express as px
from sklearn.preprocessing import MinMaxScaler
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, LSTM
from warnings import filterwarnings 
filterwarnings("ignore")
In [2]:
google_stock=pd.read_csv("C:\\Users\\laxma\\Downloads\\GOOG.csv")
google_stock
Out[2]:
symbol date close high low open volume adjClose adjHigh adjLow adjOpen adjVolume divCash splitFactor
0 GOOG 2016-06-14 00:00:00+00:00 718.27 722.470 713.1200 716.48 1306065 718.27 722.470 713.1200 716.48 1306065 0.0 1.0
1 GOOG 2016-06-15 00:00:00+00:00 718.92 722.980 717.3100 719.00 1214517 718.92 722.980 717.3100 719.00 1214517 0.0 1.0
2 GOOG 2016-06-16 00:00:00+00:00 710.36 716.650 703.2600 714.91 1982471 710.36 716.650 703.2600 714.91 1982471 0.0 1.0
3 GOOG 2016-06-17 00:00:00+00:00 691.72 708.820 688.4515 708.65 3402357 691.72 708.820 688.4515 708.65 3402357 0.0 1.0
4 GOOG 2016-06-20 00:00:00+00:00 693.71 702.480 693.4100 698.77 2082538 693.71 702.480 693.4100 698.77 2082538 0.0 1.0
... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
1253 GOOG 2021-06-07 00:00:00+00:00 2466.09 2468.000 2441.0725 2451.32 1192453 2466.09 2468.000 2441.0725 2451.32 1192453 0.0 1.0
1254 GOOG 2021-06-08 00:00:00+00:00 2482.85 2494.495 2468.2400 2479.90 1253253 2482.85 2494.495 2468.2400 2479.90 1253253 0.0 1.0
1255 GOOG 2021-06-09 00:00:00+00:00 2491.40 2505.000 2487.3300 2499.50 1006337 2491.40 2505.000 2487.3300 2499.50 1006337 0.0 1.0
1256 GOOG 2021-06-10 00:00:00+00:00 2521.60 2523.260 2494.0000 2494.01 1561733 2521.60 2523.260 2494.0000 2494.01 1561733 0.0 1.0
1257 GOOG 2021-06-11 00:00:00+00:00 2513.93 2526.990 2498.2900 2524.92 1262309 2513.93 2526.990 2498.2900 2524.92 1262309 0.0 1.0

1258 rows × 14 columns

In [3]:
google_stock.head()
Out[3]:
symbol date close high low open volume adjClose adjHigh adjLow adjOpen adjVolume divCash splitFactor
0 GOOG 2016-06-14 00:00:00+00:00 718.27 722.47 713.1200 716.48 1306065 718.27 722.47 713.1200 716.48 1306065 0.0 1.0
1 GOOG 2016-06-15 00:00:00+00:00 718.92 722.98 717.3100 719.00 1214517 718.92 722.98 717.3100 719.00 1214517 0.0 1.0
2 GOOG 2016-06-16 00:00:00+00:00 710.36 716.65 703.2600 714.91 1982471 710.36 716.65 703.2600 714.91 1982471 0.0 1.0
3 GOOG 2016-06-17 00:00:00+00:00 691.72 708.82 688.4515 708.65 3402357 691.72 708.82 688.4515 708.65 3402357 0.0 1.0
4 GOOG 2016-06-20 00:00:00+00:00 693.71 702.48 693.4100 698.77 2082538 693.71 702.48 693.4100 698.77 2082538 0.0 1.0
In [4]:
google_stock.tail()
Out[4]:
symbol date close high low open volume adjClose adjHigh adjLow adjOpen adjVolume divCash splitFactor
1253 GOOG 2021-06-07 00:00:00+00:00 2466.09 2468.000 2441.0725 2451.32 1192453 2466.09 2468.000 2441.0725 2451.32 1192453 0.0 1.0
1254 GOOG 2021-06-08 00:00:00+00:00 2482.85 2494.495 2468.2400 2479.90 1253253 2482.85 2494.495 2468.2400 2479.90 1253253 0.0 1.0
1255 GOOG 2021-06-09 00:00:00+00:00 2491.40 2505.000 2487.3300 2499.50 1006337 2491.40 2505.000 2487.3300 2499.50 1006337 0.0 1.0
1256 GOOG 2021-06-10 00:00:00+00:00 2521.60 2523.260 2494.0000 2494.01 1561733 2521.60 2523.260 2494.0000 2494.01 1561733 0.0 1.0
1257 GOOG 2021-06-11 00:00:00+00:00 2513.93 2526.990 2498.2900 2524.92 1262309 2513.93 2526.990 2498.2900 2524.92 1262309 0.0 1.0
In [5]:
google_stock.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 1258 entries, 0 to 1257
Data columns (total 14 columns):
 #   Column       Non-Null Count  Dtype  
---  ------       --------------  -----  
 0   symbol       1258 non-null   object 
 1   date         1258 non-null   object 
 2   close        1258 non-null   float64
 3   high         1258 non-null   float64
 4   low          1258 non-null   float64
 5   open         1258 non-null   float64
 6   volume       1258 non-null   int64  
 7   adjClose     1258 non-null   float64
 8   adjHigh      1258 non-null   float64
 9   adjLow       1258 non-null   float64
 10  adjOpen      1258 non-null   float64
 11  adjVolume    1258 non-null   int64  
 12  divCash      1258 non-null   float64
 13  splitFactor  1258 non-null   float64
dtypes: float64(10), int64(2), object(2)
memory usage: 137.7+ KB
In [6]:
google_stock.describe()
Out[6]:
close high low open volume adjClose adjHigh adjLow adjOpen adjVolume divCash splitFactor
count 1258.000000 1258.000000 1258.000000 1258.000000 1.258000e+03 1258.000000 1258.000000 1258.000000 1258.000000 1.258000e+03 1258.0 1258.0
mean 1216.317067 1227.430934 1204.176430 1215.260779 1.601590e+06 1216.317067 1227.430936 1204.176436 1215.260779 1.601590e+06 0.0 1.0
std 383.333358 387.570872 378.777094 382.446995 6.960172e+05 383.333358 387.570873 378.777099 382.446995 6.960172e+05 0.0 0.0
min 668.260000 672.300000 663.284000 671.000000 3.467530e+05 668.260000 672.300000 663.284000 671.000000 3.467530e+05 0.0 1.0
25% 960.802500 968.757500 952.182500 959.005000 1.173522e+06 960.802500 968.757500 952.182500 959.005000 1.173522e+06 0.0 1.0
50% 1132.460000 1143.935000 1117.915000 1131.150000 1.412588e+06 1132.460000 1143.935000 1117.915000 1131.150000 1.412588e+06 0.0 1.0
75% 1360.595000 1374.345000 1348.557500 1361.075000 1.812156e+06 1360.595000 1374.345000 1348.557500 1361.075000 1.812156e+06 0.0 1.0
max 2521.600000 2526.990000 2498.290000 2524.920000 6.207027e+06 2521.600000 2526.990000 2498.290000 2524.920000 6.207027e+06 0.0 1.0
In [7]:
google_stock.isnull().sum()
Out[7]:
symbol         0
date           0
close          0
high           0
low            0
open           0
volume         0
adjClose       0
adjHigh        0
adjLow         0
adjOpen        0
adjVolume      0
divCash        0
splitFactor    0
dtype: int64
In [8]:
google_stock.duplicated().sum()
Out[8]:
0
In [9]:
google_stock.columns
Out[9]:
Index(['symbol', 'date', 'close', 'high', 'low', 'open', 'volume', 'adjClose',
       'adjHigh', 'adjLow', 'adjOpen', 'adjVolume', 'divCash', 'splitFactor'],
      dtype='object')
In [10]:
plt.scatter(google_stock['volume'],google_stock['high'])
plt.xticks(rotation=90)
plt.show()
In [11]:
Tesla_volume = google_stock["volume"]
Tesla_volume
Out[11]:
0       1306065
1       1214517
2       1982471
3       3402357
4       2082538
         ...   
1253    1192453
1254    1253253
1255    1006337
1256    1561733
1257    1262309
Name: volume, Length: 1258, dtype: int64
In [12]:
Tesla_open = google_stock["open"]
Tesla_open
Out[12]:
0        716.48
1        719.00
2        714.91
3        708.65
4        698.77
         ...   
1253    2451.32
1254    2479.90
1255    2499.50
1256    2494.01
1257    2524.92
Name: open, Length: 1258, dtype: float64
In [13]:
plt.figure(figsize=(8,6))
plt.plot(Tesla_open.index, Tesla_open, label='Tesla_open ($)', color='m')
plt.title('Tesla Open Prices between open ($) and volume')
plt.xlabel('volume')
plt.ylabel('open ($)')
plt.legend()
plt.show()
In [14]:
fig =px.histogram(google_stock, x='adjOpen' ,y='adjHigh')
fig.update_xaxes(title='adjOpen')
fig.update_yaxes(title='adjHigh')
fig.show()
In [15]:
fig =px.line(google_stock, x='open', y='date')
fig.update_xaxes(title='open')
fig.update_yaxes(title='date')
plt.figure(figsize=(8,6))
fig.show()
<Figure size 800x600 with 0 Axes>
In [16]:
daily_changes = google_stock['volume'].diff()
fig = px.histogram(daily_changes, nbins=50, title='Histogram of Daily stocks open and close')
fig.update_xaxes(title='open')
fig.update_yaxes(title='close')
fig.update_layout(template='plotly_white')
fig.show()
In [17]:
import seaborn as sns
In [18]:
sns.heatmap(google_stock.corr())
Out[18]:
<AxesSubplot:>
In [19]:
plt.figure(figsize=(12, 12))
sns.scatterplot(google_stock['volume'],google_stock['high'],color='r')
plt.xticks(rotation=90)
plt.show()